﻿using Microsoft.Extensions.DependencyInjection;

namespace _3Dto2D;

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        IServiceProvider? serviceProvider = null;
        try
        {
            serviceProvider = ServiceConfiguration.BuildServiceProvider();

            var app = new App(serviceProvider);
            app.Run();
        }
        catch (Exception ex)
        {
            // Fallback error message if logging fails
            MessageBox.Show($"A critical error occurred during startup: {ex.Message}",
                "Startup Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            if (serviceProvider is IDisposable disposableProvider)
            {
                disposableProvider.Dispose();
            }
        }
    }
}
